package rmi;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

public class RmiServer {

    public static void main(String []args) throws RemoteException, MalformedURLException {

        UserManagerImpl userManager=new UserManagerImpl();
        UserManagerInterface userManagerI=(UserManagerInterface) UnicastRemoteObject.exportObject(userManager,0);
        // Bind the remote object's stub in the registry
        Registry registry = LocateRegistry.createRegistry(2001);
        registry.rebind("userManager", userManagerI);

        // 启动时指定-Djava.rmi.server.hostname=192.168.57.234，否则客户端运行期报异常，

        // 无法获取-Dcom.sun.management.jmxremote.port
    //    registry = LocateRegistry.getRegistry(8288);

        System.out.println("server is ready");

    }

}
